<?php
class admin_listController extends adminController{

    //首页
    public function index() {
        //获取广告位列表
        $this->list=model('advertising')->advertising_list();
        $this->type_list=model('advertising')->type_list();
        $this->show();  
    }

    //添加
    public function add() {
        $type=$_GET['type'];
        $this->alert_str($type,'int');
        $this->type=$type;
        $this->action_name='添加';
        $this->action='add';
        $this->show('admin_list/info_'.$type); 
    }

    public function add_save() {
        //录入模型处理
        $id=model('advertising')->add($_POST);
        api('editor','relation',array('table'=>'advertising','file_id'=>$_POST['file_id'],'id'=>$id));
        $this->msg('广告位添加成功！',1);
    }

    //修改
    public function edit() {
        $id=$_GET['id'];
        $this->alert_str($id,'int');
        $this->file_id=api('editor','get_relation',array('table'=>'advertising','id'=>$id));
        $this->info=model('advertising')->info($id);
        $this->type=$this->info['type'];
        $this->action_name='编辑';
        $this->action='edit';
        $this->show('admin_list/info_'.$this->info['type']); 
    }

    public function edit_save() {
        $id=$_POST['id'];
        $this->alert_str($id,'int',true);
        //录入模型处理
        model('advertising')->edit($_POST);
        api('editor','relation',array('table'=>'advertising','file_id'=>$_POST['file_id'],'id'=>$_POST['id']));
        $this->msg('广告位修改成功! ',1);
    }

    //删除
    public function del() {
        $id=intval($_POST['id']);
        $this->alert_str($id,'int',true); 
        //录入模型处理
        model('advertising')->del($id);
        api('editor','del_file',array('table'=>'advertising','id'=>$id));
        $this->msg('广告位删除成功！',1);
    }

    //多图片上传
    public function images_upload(){
        $this->id=in($_GET['id']);
        $this->show();
    }


}